﻿using Newtonsoft.Json;
using RecipeDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace RecipeDemo.ViewModels
{
    public class ScanPointRepository
    {
        private readonly Dictionary<Guid, ScanPointItem> _items = new();

        public void AddOrUpdate(ScanPointItem item)
        {
            _items[item.Id] = item;
        }

        public ScanPointItem GetById(Guid id) => _items.ContainsKey(id) ? _items[id] : null;

        public string ExportToJson()
        {
            return JsonConvert.SerializeObject(_items.Values, new JsonSerializerSettings
            {
                Formatting = Newtonsoft.Json.Formatting.Indented,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });
        }
    }
}
